package com.lxj.student_security.controller;

import com.lxj.student_security.common.CommonResult;
import com.lxj.student_security.entity.Permission;
import com.lxj.student_security.entity.vo.Tree;
import com.lxj.student_security.service.PermissionService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/permission")
//@CrossOrigin(origins = "*",maxAge = 3600)
public class PermissionController {
    @Autowired
    private PermissionService permissionService;

    @PostMapping("/searchAll")
    public CommonResult searchAll(Permission permission) {
        return permissionService.searchAll(permission);
    }
    @PostMapping("/findAll")
    public CommonResult findAll(){
        return permissionService.findAll();
    }
    @PostMapping("/delete")
    public CommonResult delete(Integer[] id) {
        return permissionService.delete(id);
    }

    @PostMapping("/add")
    public CommonResult add(Permission permission) {
        return permissionService.add(permission);
    }

    @PostMapping("/edit")
    public CommonResult edit(Permission permission) {
        return permissionService.edit(permission);
    }

    @PostMapping("/findById")
    public CommonResult findById(Integer id) {
        return permissionService.findById(id);
    }

    @GetMapping("/persTree")
    public Tree<Permission> tree() {
        return permissionService.tree();
    }
    @PostMapping("/getMenu")
    public Tree<Permission> getMenu(String username){
        return permissionService.getMenu(username);
    }
}
